package com.cy.proxy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Proxu {
    public static Object invoke(Object target, String met) throws InvocationTargetException, IllegalAccessException {
        Method m1=null;
        Method[] methods = target.getClass().getMethods();
        for(Method method:methods){
            if(method.getName().equals(met)){
                method.setAccessible(true);
                m1 = method;
                break;
            }
        }
        System.out.println("before添加");
        Object result = m1.invoke(target);
        System.out.println("after添加");
        return result;
    }
}
